﻿#ifndef __SS_DB_POLL_THREAD_H__
#define __SS_DB_POLL_THREAD_H__
#include "thread/ssMsgThread.h"
#include "message/ssNetMsgHead.h"
#include "ssMySQLPool.h"


namespace StarSeeker
{

class ssDBPoolThread : public StarSeeker::ssMsgThread
{
public:
	ssDBPoolThread();
	ssDBPoolThread(ssMySQLPool* c);
	~ssDBPoolThread();
protected:
	//设置连接池
	void SetMySQLPool(ssMySQLPool* c);
	//查询路由，由子类实现
	virtual bool OnDBMsg(ssNetMsgHead* pHead, const char* pData, const u32 dataLen, u32 connectID) = 0;
	//发送查询回包
	virtual void SendResponse(u32 connectID, ssNetMsgHead* pHead, char* pData, u32 len) = 0;
	//执行查询的函数
	bool OnDBMsgNullRecord(u32 id, ssNetMsgHead* pHead, const char* pData, const u32 dataLen, u32 connectID);
	bool OnDBMsgOneRecord(u32 id, ssNetMsgHead* pHead, const char* pData, const u32 dataLen, u32 connectID);
	bool OnDBMsgMultiRecord(u32 id, ssNetMsgHead* pHead, const char* pData, const u32 dataLen, u32 connectID);
	void OnDBMsgCleanBuffer();
private:
	//消息处理
	void HandleMessage(ssMsg_s &m);

protected:
	ssMySQLPool	*		m_mysqlPool;
};

}
#endif
